<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        // 函数 简单数据类型
        const wes = Symbol('wes');

        // Symbol()具有唯一性，形式上是函数，但它是一个简单数据类型
        console.log(Symbol() == Symbol()); //false
        console.log(wes, typeof wes);
        // const classRoom = {
        //     "东理faker": "Mr Li",
        //     "东理faker": "Mr lang",
        //     [Symbol()]: "Mr Li",
        //     [Symbol()]: "Mr lang"
        // }
        const classRoom = {
            [Symbol('刘全能')]: "刘印",
            [Symbol('刘全能')]: "刘天昊",
            [Symbol('Mark')]: {
                grade: 50,
                gender: 'male'
            },
            [Symbol('olivia')]: {
                grade: 80,
                gender: 'female'
            },
            [Symbol('olivia')]: {
                grade: 80,
                gender: 'female'
            }
        };
        // console.log(Object.keys(classRoom));
        const keys = Object.keys(classRoom);
        const syms = Object.getOwnPropertySymbols(classRoom);
        // console.log(syms);
        for (let key of keys) {
            console.log(classRoom[key]);
        };
        for (let sym of syms) {
            console.log(classRoom[sym]);
        };
        const data = [...keys.map(key => classRoom[key]), ...syms.map(sym => classRoom)];
        console.log(data);

        // synbol 可以给对象带来唯一性，但是它与传统的key泾渭分明，Object.keys()拿不到对应的属性
        for (const person in classRoom) {
            console.log(person);
        }
    </script>
</body>

</html>